package zhouzhouyongche.model;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;

@Entity
@Table
@DynamicInsert(true)
@DynamicUpdate(true)
public class City implements Serializable{

	private static final long serialVersionUID = 1L;

	//主键
	private int id;
	
    private String cityName;
    
    private Set<PassengerStation> passengerStationList;
    
    private Set<Site> siteList;
    
    @Id
    @GeneratedValue(generator = "generator")
	@GenericGenerator(name = "generator", strategy = "identity")
    public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}
    
	@Column(nullable = false)
	public String getCityName() {
		return cityName;
	}

	public void setCityName(String cityName) {
		this.cityName = cityName;
	}

	//单向关系， One To Many
	@OneToMany(fetch = FetchType.EAGER)
	@JoinColumn(name = "city_id")
	public Set<PassengerStation> getPassengerStationList() {
		return passengerStationList;
	}

	public void setPassengerStationList(Set<PassengerStation> passengerStationList) {
		this.passengerStationList = passengerStationList;
	}

	//单向关系， One To Many
	@OneToMany(fetch = FetchType.EAGER)
	@JoinColumn(name = "city_id")
	public Set<Site> getSiteList() {
		return siteList;
	}

	public void setSiteList(Set<Site> siteList) {
		this.siteList = siteList;
	}

}
